package com.ruoyi.board.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.board.domain.StockBoardIndustryConsEm;
import com.ruoyi.board.service.IStockBoardIndustryConsEmService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 东方财富-成份股Controller
 * 
 * @author leng.xz
 * @date 2024-05-17
 */
@Controller
@RequestMapping("/board/IndustryConsEm")
public class StockBoardIndustryConsEmController extends BaseController
{
    private String prefix = "board/IndustryConsEm";

    @Autowired
    private IStockBoardIndustryConsEmService stockBoardIndustryConsEmService;

    @RequiresPermissions("board:IndustryConsEm:view")
    @GetMapping()
    public String IndustryConsEm()
    {
        return prefix + "/IndustryConsEm";
    }

    /**
     * 查询东方财富-成份股列表
     */
    @RequiresPermissions("board:IndustryConsEm:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(StockBoardIndustryConsEm stockBoardIndustryConsEm)
    {
        startPage();
        List<StockBoardIndustryConsEm> list = stockBoardIndustryConsEmService.selectStockBoardIndustryConsEmList(stockBoardIndustryConsEm);
        return getDataTable(list);
    }

    /**
     * 导出东方财富-成份股列表
     */
    @RequiresPermissions("board:IndustryConsEm:export")
    @Log(title = "东方财富-成份股", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(StockBoardIndustryConsEm stockBoardIndustryConsEm)
    {
        List<StockBoardIndustryConsEm> list = stockBoardIndustryConsEmService.selectStockBoardIndustryConsEmList(stockBoardIndustryConsEm);
        ExcelUtil<StockBoardIndustryConsEm> util = new ExcelUtil<StockBoardIndustryConsEm>(StockBoardIndustryConsEm.class);
        return util.exportExcel(list, "IndustryConsEm");
    }

    /**
     * 新增东方财富-成份股
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存东方财富-成份股
     */
    @RequiresPermissions("board:IndustryConsEm:add")
    @Log(title = "东方财富-成份股", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(StockBoardIndustryConsEm stockBoardIndustryConsEm)
    {
        return toAjax(stockBoardIndustryConsEmService.insertStockBoardIndustryConsEm(stockBoardIndustryConsEm));
    }

    /**
     * 修改东方财富-成份股
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        StockBoardIndustryConsEm stockBoardIndustryConsEm = stockBoardIndustryConsEmService.selectStockBoardIndustryConsEmById(id);
        mmap.put("stockBoardIndustryConsEm", stockBoardIndustryConsEm);
        return prefix + "/edit";
    }

    /**
     * 修改保存东方财富-成份股
     */
    @RequiresPermissions("board:IndustryConsEm:edit")
    @Log(title = "东方财富-成份股", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(StockBoardIndustryConsEm stockBoardIndustryConsEm)
    {
        return toAjax(stockBoardIndustryConsEmService.updateStockBoardIndustryConsEm(stockBoardIndustryConsEm));
    }

    /**
     * 删除东方财富-成份股
     */
    @RequiresPermissions("board:IndustryConsEm:remove")
    @Log(title = "东方财富-成份股", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(stockBoardIndustryConsEmService.deleteStockBoardIndustryConsEmByIds(ids));
    }
}
